﻿//-----------------------------------------------------------------------
// <copyright file="SearchSuggestionCollection.cs" company="In The Hand Ltd">
//     Copyright © 2013-14 In The Hand Ltd. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

using System.Collections.ObjectModel;
using Windows.Storage.Streams;

namespace InTheHand.ApplicationModel.Search
{
    /// <summary>
    /// Represents a collection of search suggestions to be displayed in the search pane in response to a suggestionsrequested event.
    /// </summary>
    public sealed class SearchSuggestionCollection
    {
        private ObservableCollection<string> suggestions = new ObservableCollection<string>();

        internal SearchSuggestionCollection()
        {
        }

        internal void Clear()
        {
            suggestions.Clear();
        }

        internal ObservableCollection<string> Suggestions
        {
            get
            {
                return suggestions;
            }
        }

        /// <summary>
        /// The number of suggestions in the collection.
        /// </summary>
        [System.CLSCompliant(false)]
        public uint Size
        {
            get
            {
                return (uint)suggestions.Count;
            }
        }

        /// <summary>
        /// Appends a suggested search result to the list of suggestions to display in the search pane.
        /// </summary>
        /// <param name="text">The text of the suggested result.</param>
        /// <param name="detailText"></param>
        /// <param name="tag"></param>
        /// <param name="image"></param>
        /// <param name="imageAlternateText"></param>
        [System.CLSCompliant(false)]
        public void AppendResultSuggestion(string text, string detailText, string tag, IRandomAccessStreamReference image, string imageAlternateText)
        {
            if (!suggestions.Contains(text))
            {
                suggestions.Add(text);
            }
        }
    }
}
